#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'tian'
__data__ = '2021/12/7 16:20'
# software: PyCharm

from django.conf import settings


def upload_image(request, image_object, key):
    """
    markdown上传图片保存到本地
    :param request:
    :param image_object:
    :param key:
    :return:
    """
    imag_path = "{0}\wiki\{1}".format(settings.MEDIA_ROOT, key)
    with open(imag_path, "wb") as wr:
        for i in image_object.chunks():
            wr.write(i)
    return "{0}/media/wiki/{1}".format(settings.IMAGE_URL, key)
